import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import { PlatformTransformer } from 'uni-platform-chain'


const platform = process.env.UNI_PLATFORM || '';

console.log(platform)

// 获取当前构建平台
const getPlatform = () => {
  const platform = process.env.UNI_PLATFORM || '';

  // 平台映射
  const platformMap = {
    'app': 'APP',
    'h5': 'WEB',
    'mp-alipay': 'MP_ALIPAY',
    'mp-baidu': 'MP_BAIDU',
    'mp-jd': 'MP_JD',
    'mp-kuaishou': 'MP_KUAISHOU',
    'mp-lark': 'MP_LARK',
    'mp-qq': 'MP_QQ',
    'mp-toutiao': 'MP_TOUTIAO',
    'mp-weixin': 'MP_WEIXIN',
    'mp-360': 'MP_360',
    'mp-xhs': 'MP_XHS',
    'quickapp-webview': 'QUICKAPP_WEBVIEW',
    'quickapp-webview-union': 'QUICKAPP_WEBVIEW_UNION',
    'quickapp-webview-huawei': 'QUICKAPP_WEBVIEW_HUAWEI',
  };

  return platformMap[platform] || 'WEB';
};

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    PlatformTransformer.createVitePlugin('WEB'),
    uni(),
  ],
})
